package com.wwmz.spring.simple.annotation.injections.propertysource;


import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment;

import java.util.Arrays;

/**
 * Created by wumz on 2020/9/27 10:59
 */
public class MyTest {


    @Test
    public void test(){
        ApplicationContext app = new AnnotationConfigApplicationContext(MyConfig.class);
        Object bird = app.getBean("bird");
        System.out.println(bird);

        Environment environment = app.getEnvironment();
        String property = environment.getProperty("bird.color");
        System.out.println(property);


        String [] beanNames = app.getBeanDefinitionNames();
        System.out.println(Arrays.toString(beanNames)
                .replaceAll("\\[|\\]","")
                .replaceAll(", ","\n"));
    }
}
